﻿@namespace BootstrapBlazor
@inherits BootstrapTable
@typeparam TItem

<table @ref="@Element" class="@Classname" style="@Style" @attributes="@AdditionalAttributes">
    <CascadingValue Value="@this" IsFixed>
        <thead>
            <BootstrapHeadTr MultiSelection="@MultiSelection" Items="@_items" SelectedItems="@SelectedItems">
                @if (THeadContent is not null)
                {
                    @THeadContent
                }
                else if (Columns is not null)
                {
                    <CascadingValue Name="RenderMode" Value="@TableColumn.RenderMode.Head" IsFixed>
                    @Columns(DefaultValue)
                </CascadingValue>
                }
            </BootstrapHeadTr>
        </thead>
        <tbody>
            @if (_items.Any() && Columns != null)
            {
                <CascadingValue Name="RenderMode" Value="@TableColumn.RenderMode.Body" IsFixed>
                @foreach (var item in _items)
                    {
                        <BootstrapTr MultiSelection="@MultiSelection" Item="@item" SelectedItems="@SelectedItems">
                            @Columns(item)
                        </BootstrapTr>
                    }
                </CascadingValue>
            }
        </tbody>
    </CascadingValue>
</table>
